<%@ page import="com.cgt.web.pojo.Student" %>
<%@ page import="java.util.List" %><%--
  Created by IntelliJ IDEA.
  User: DELL
  Date: 2025/1/23
  Time: 11:22
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Student</title>
    <link rel="stylesheet" href="static/bootstrap-3.4.1-dist/css/bootstrap.css">
</head>
<body>
<%--    ${list}--%>

    <%
        List<Student> list = (List<Student>) request.getAttribute("list");
    %>
    <a class="btn btn-success" href="student_add.jsp">添加</a>
    <a class="btn btn-primary" href="/student?method=tostudentAdd">添加</a>
    <table class="table table-striped table-bordered table-hover table-condensed">
        <tr>
            <td>ID</td>
            <td>姓名</td>
            <td>年龄</td>
            <td>性别</td>
        </tr>
        <%
            for (Student student : list) {
        %>
                <tr>
                    <td><%=student.getId()%></td>
                    <td><%=student.getName()%></td>
                    <td><%=student.getAge()%></td>
                    <td><%=student.getGender()%></td>
                    <td><a href="/student?method=tostudentUpdate&id=<%=student.getId()%>">修改</a></td>
                    <td><a href="javascript:void(0)" onclick="deleteById(<%=student.getId()%>)">删除</a></td>
<%--                    <td><a href="/deleteStudent?id=<%=student.getId()%>">删除</a></td>--%>
                </tr>
        <%
            }
        %>
    </table>
    <script>
        function deleteById(id){
            var isDelete = confirm('真的要删除这条记录吗？');
            if(isDelete){
                // location.href = "/deleteStudent?id=" + id;
                location.href = "/student?method=deleteById&id=" + id;
            }
        }
    </script>
</body>
</html>
